<?php

class Exam_FaqController extends Core_Controller_Action_Standard {
	/**
	 * Navigation
	 * @var Zend_Navigation
	 */
	protected $_navigation = null;
		
	/* Navigation
	 * @see Zend_Controller_Action::init()
	 */
	public function init() {        
        // Get navigation
		$this->_navigation = Engine_Api::_()->getApi('menus', 'core')
			->getNavigation(
				'exam_main',
				array (),
				'exam_main_faq'			
			);

		// Assign view
		$this->view->navigation = $this->_navigation;
		
		$this->view->headLink()
                ->appendStylesheet($this->view->baseUrl('application/modules/Exam/externals/styles/fix_topmenu.css'));
	}
	
	/**
	 * List all FAQs
	 */
	public function indexAction() {
		// Get all FAQs
		$faqTable = Engine_Api::_()->getDbTable('faqs', 'exam');
		$params = array (
			"status"	=>	Exam_Model_Faq::FAQ_STATUS_ACTIVE		
		);
		$select = Engine_Api::_()->getApi('Faq', 'exam')
			->getFAQSelect($params);
		$faqs = $faqTable->fetchAll($select);
		
		// Group by category
		$faqList = array ();
		foreach ($faqs as $faq) {
			$faqList[$faq->faqcategory_name][] = $faq;
		}
		$this->view->faqList = $faqList;
	}
}
